package cn.ekuma.pos.toolcommand.base;

import java.awt.Component;
import java.util.List;

import net.xeoh.plugins.base.annotations.PluginImplementation;

import com.openbravo.bean.Location;
import com.openbravo.bean.Product;
import com.openbravo.data.basic.BasicException;
import com.openbravo.pos.panels.JObjectListFinder;

import cn.ekuma.epos.datalogic.define.dao.ProductDAO;
import cn.ekuma.epos.toolcommand.AbstractCommand;

@PluginImplementation
public class BomStoreBalanceCommand extends AbstractCommand {
	ProductDAO productDao;
	
	@Override
	public void call() throws BasicException {
		productDao=(ProductDAO) dataLogic.getDao(Product.class);
		List<Product> bomProduct=productDao.listNoStoreProductBom();
		List locations=dataLogic.list(Location.class);
		Location location=(Location)JObjectListFinder.newJDialog((Component) app).showUserList(locations);
		if(location==null)
			return;
		for(Product p:bomProduct){
			dataLogic.productBomBalance(location.getID(), p.getID());
		}
	}

	@Override
	public String getCommandName() {
		return "BomStoreBalance";
	}

	@Override
	public String getCommandCategoryName() {
		return "base";
	}
}
